package com.lei.app.entity.base;

import org.nutz.dao.entity.annotation.*;
import org.nutz.lang.Strings;
import org.nutz.lang.random.R;
import org.nutz.mvc.Mvcs;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;

/**
 * @author 郑兴泉 956607644@qq.com
 * @data 2020/4/9
 * 描述：
 */
public abstract class BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @Column("ctBy")
    @Comment("操作人")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String opBy;

    @Column("ctAt")
    @Comment("操作时间")
    @ColDefine(type = ColType.TIMESTAMP)
    private Timestamp opAt;

    @Column("upBy")
    @Comment("创建人")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    protected String upBy;

    @Column("upAt")
    @Comment("创建时间")
    @Prev(els = @EL("$me.dateNow()"))
    @ColDefine(type = ColType.TIMESTAMP)
    protected Timestamp upAt;

    @Column
    @Comment("删除标记")
    @Prev(els = @EL("$me.flag()"))
    @ColDefine(type = ColType.BOOLEAN)
    private Boolean delFlag;

    public Date dateNow() {
        return new Date(System.currentTimeMillis());
    }

    public String uid() {

        return "";
    }

    public String getOpBy() {
        return opBy;
    }

    public void setOpBy(String opBy) {
        this.opBy = opBy;
    }

    public Timestamp getOpAt() {
        return opAt;
    }

    public void setOpAt(Timestamp opAt) {
        this.opAt = opAt;
    }

    public String getUpBy() {
        return upBy;
    }

    public void setUpBy(String upBy) {
        this.upBy = upBy;
    }

    public Timestamp getUpAt() {
        return upAt;
    }

    public void setUpAt(Timestamp upAt) {
        this.upAt = upAt;
    }

    public Boolean getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(Boolean delFlag) {
        this.delFlag = delFlag;
    }

    public String uuid() {
        return R.UU32().toLowerCase();
    }

    public Boolean flag() {
        return false;
    }

    public Timestamp now() {
        return new Timestamp(System.currentTimeMillis());
    }
}
